package com.springboot.frame.comm.config;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.io.File;


/**
 * 全局配置
 *
 * @author madman
 */
@Getter
public final class GlobalConfig {

  /**
   * 默认实例
   */
  public static final GlobalConfig INSTANCE = new GlobalConfig();
  /**
   * 生成文件的输出目录
   */
  private String outputDir = "C:\\Users\\lihen\\Desktop\\temps\\code";
  /**
   * 是否覆盖更新，启用的话重复代码生成会覆盖已有的，关闭的话只会生成新文件
   */
  private boolean fileOverride = true;
  /**
   * 是否在xml中添加二级缓存配置
   */
  private boolean enableCache = false;
  /**
   * 是否启用lombok,默认启用
   */
  private boolean enableLombok = true;
  /**
   * 是否自动下划线转驼峰<p> 如：Mybatis</p>
   */
  private boolean autoToCamel = true;
  /**
   * 实体类的父类<p>如：通用字段可放父类<p/>
   */
  private Class<?> superClass;

  /**
   * 设置输出路径
   *
   * @param outputDir 输出路径
   */
  public GlobalConfig outputDir(String outputDir) {
    this.outputDir =
        !StringUtils.endsWith(outputDir, File.separator) ? outputDir + File.separator : outputDir;
    return this;
  }

  public GlobalConfig fileOverride(boolean fileOverride) {
    this.fileOverride = fileOverride;
    return this;
  }

  public GlobalConfig enableCache(boolean enableCache) {
    this.enableCache = enableCache;
    return this;
  }

  public GlobalConfig enableLombok(boolean enableLombok) {
    this.enableLombok = enableLombok;
    return this;
  }

  public GlobalConfig autoToCamel(boolean autoToCamel) {
    this.autoToCamel = autoToCamel;
    return this;
  }

  public GlobalConfig superClass(Class<?> superClass) {
    this.superClass = superClass;
    return this;
  }

}
